<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <!--      <el-form-item label="电子档案案卷表" prop="eaid">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.eaid"-->
      <!--          placeholder="请输入电子档案案卷表"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="案卷级档案表" prop="aid">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.aid"-->
      <!--          placeholder="请输入案卷级档案表"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="文件名" prop="wenJianName">
        <el-input
          v-model="queryParams.wenJianName"
          placeholder="请输入文件名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="文件数" prop="pageShu">
        <el-input
          v-model="queryParams.pageShu"
          placeholder="请输入文件数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="文件目录" prop="fileDirectory">
        <el-input
          v-model="queryParams.fileDirectory"
          placeholder="请输入文件目录"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="状态值" prop="state">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.state"-->
      <!--          placeholder="请输入状态值 0：表示未被绑定  1：表示已被绑定"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="创建时间" prop="creationTime">-->
      <!--        <el-date-picker clearable-->
      <!--          v-model="queryParams.creationTime"-->
      <!--          type="date"-->
      <!--          value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择创建时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件id" prop="fileId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.fileId"-->
      <!--          placeholder="请输入文件id"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件编号" prop="efilenum">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.efilenum"-->
      <!--          placeholder="请输入文件编号"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="${comment}" prop="listnum">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.listnum"-->
      <!--          placeholder="请输入${comment}"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="列表号" prop="listId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.listId"-->
      <!--          placeholder="请输入列表号"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="索引id" prop="indexId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.indexId"-->
      <!--          placeholder="请输入索引id"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="案卷ID" prop="volumeid">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.volumeid"-->
      <!--          placeholder="请输入案卷ID"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="旧案卷ID" prop="oldvolumeid">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.oldvolumeid"-->
      <!--          placeholder="请输入旧案卷ID"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件题名" prop="filename">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.filename"-->
      <!--          placeholder="请输入文件题名"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="责任者" prop="duty">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.duty"-->
      <!--          placeholder="请输入责任者"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件编号" prop="tagnum">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.tagnum"-->
      <!--          placeholder="请输入文件编号"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="${comment}" prop="filenum">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.filenum"-->
      <!--          placeholder="请输入${comment}"-->
      <!--          clearable-->
      <!--&lt;!&ndash;          @keyup.enter.native="handleQuery"&ndash;&gt;-->
      <!--&lt;!&ndash;        />&ndash;&gt;-->
      <!--      </el-form-item>-->
      <el-form-item label="主题词" prop="thematic">
        <el-input
          v-model="queryParams.thematic"
          placeholder="请输入主题词"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="创建时间" prop="ctime">-->
      <!--        <el-date-picker clearable-->
      <!--          v-model="queryParams.ctime"-->
      <!--          type="date"-->
      <!--          value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择创建时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="页数" prop="pagenumber">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.pagenumber"-->
      <!--          placeholder="请输入页数"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="密级" prop="securitylayer">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.securitylayer"-->
      <!--          placeholder="请输入密级"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="文件类型" prop="filetype">
        <el-input
          v-model="queryParams.filetype"
          placeholder="请输入文件类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="保存期限" prop="savetime">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.savetime"-->
      <!--          placeholder="请输入保存期限"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件时间" prop="filetime">-->
      <!--        <el-date-picker clearable-->
      <!--          v-model="queryParams.filetime"-->
      <!--          type="date"-->
      <!--          value-format="yyyy-MM-dd"-->
      <!--          placeholder="请选择文件时间">-->
      <!--        </el-date-picker>-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件号" prop="fileno">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.fileno"-->
      <!--          placeholder="请输入文件号"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="附件" prop="fileatt">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.fileatt"-->
      <!--          placeholder="请输入附件"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="载体类型" prop="carriertype">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.carriertype"-->
      <!--          placeholder="请输入载体类型"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件总数量" prop="totalnum">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.totalnum"-->
      <!--          placeholder="请输入文件总数量"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="总数量" prop="total">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.total"-->
      <!--          placeholder="请输入总数量"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="纸张类型" prop="papertype">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.papertype"-->
      <!--          placeholder="请输入纸张类型"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="建设单位" prop="buildorganization">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.buildorganization"-->
      <!--          placeholder="请输入建设单位"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="编制单位" prop="wcompanyId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.wcompanyId"-->
      <!--          placeholder="请输入编制单位"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="档号" prop="vnum">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.vnum"-->
      <!--          placeholder="请输入档号"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="是否归档" prop="isArchived">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.isArchived"-->
      <!--          placeholder="请输入是否归档"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="项目索引" prop="projIndex">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.projIndex"-->
      <!--          placeholder="请输入项目索引"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="附注" prop="comments">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.comments"-->
      <!--          placeholder="请输入附注"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="摘要" prop="abstracts">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.abstracts"-->
      <!--          placeholder="请输入摘要"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="关键字" prop="keywords">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.keywords"-->
      <!--          placeholder="请输入关键字"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="电子文件存放路径" prop="filepath">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.filepath"-->
      <!--          placeholder="请输入电子文件存放路径"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="文件信息预留1" prop="fileReserved1">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.fileReserved1"-->
      <!--          placeholder="请输入文件信息预留1"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="${comment}" prop="fileReserved2">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.fileReserved2"-->
      <!--          placeholder="请输入${comment}"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:file:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate1"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:file:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:file:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="fileList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="编号" align="center" prop="id" v-if="columns[0].visible"/>
      <el-table-column label="电子档案案卷表" align="center" prop="eaid" v-if="columns[1].visible"/>
      <el-table-column label="案卷级档案表" align="center" prop="aid" v-if="columns[2].visible"/>
      <el-table-column label="文件名" align="center" prop="wenJianName" v-if="columns[3].visible"/>
      <el-table-column label="文件数" align="center" prop="pageShu" v-if="columns[4].visible"/>
      <el-table-column label="文件目录" align="center" prop="fileDirectory" v-if="columns[5].visible"/>
      <el-table-column label="状态值 " align="center" prop="state" v-if="columns[6].visible"/>
      <el-table-column label="创建时间" align="center" prop="creationTime" width="180" v-if="columns[7].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.creationTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="文件id" align="center" prop="fileId" v-if="columns[8].visible"/>
      <el-table-column label="文件编号" align="center" prop="efilenum" v-if="columns[9].visible"/>
      <!--      <el-table-column label="${comment}" align="center" prop="listnum" />-->
      <el-table-column label="列表号" align="center" prop="listId" v-if="columns[10].visible"/>
      <el-table-column label="索引id" align="center" prop="indexId" v-if="columns[11].visible"/>
      <el-table-column label="案卷ID" align="center" prop="volumeid" v-if="columns[12].visible"/>
      <el-table-column label="旧案卷ID" align="center" prop="oldvolumeid" v-if="columns[13].visible"/>
      <el-table-column label="文件题名" align="center" prop="filename" v-if="columns[14].visible"/>
      <el-table-column label="责任者" align="center" prop="duty" v-if="columns[15].visible"/>
      <el-table-column label="文件编号" align="center" prop="tagnum" v-if="columns[16].visible"/>
      <!--      <el-table-column label="${comment}" align="center" prop="filenum" />-->
      <el-table-column label="主题词" align="center" prop="thematic" v-if="columns[17].visible"/>
      <el-table-column label="创建时间" align="center" prop="ctime" width="180" v-if="columns[18].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ctime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="页数" align="center" prop="pagenumber" v-if="columns[19].visible"/>
      <el-table-column label="密级" align="center" prop="securitylayer" v-if="columns[20].visible"/>
      <el-table-column label="文件类型" align="center" prop="filetype" v-if="columns[21].visible"/>
      <el-table-column label="保存期限" align="center" prop="savetime" v-if="columns[22].visible"/>
      <el-table-column label="文件时间" align="center" prop="filetime" width="180" v-if="columns[23].visible">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.filetime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="文件号" align="center" prop="fileno" v-if="columns[24].visible"/>
      <el-table-column label="附件" align="center" prop="fileatt" v-if="columns[25].visible"/>
      <el-table-column label="载体类型" align="center" prop="carriertype" v-if="columns[26].visible"/>
      <el-table-column label="文件总数量" align="center" prop="totalnum" v-if="columns[27].visible"/>
      <el-table-column label="总数量" align="center" prop="total"v-if="columns[28].visible" />
      <el-table-column label="纸张类型" align="center" prop="papertype" v-if="columns[29].visible"/>
      <el-table-column label="建设单位" align="center" prop="buildorganization" v-if="columns[30].visible"/>
      <el-table-column label="编制单位" align="center" prop="wcompanyId" v-if="columns[31].visible"/>
      <el-table-column label="档号" align="center" prop="vnum" v-if="columns[32].visible"/>
      <el-table-column label="是否归档" align="center" prop="isArchived" v-if="columns[33].visible"/>
      <el-table-column label="项目索引" align="center" prop="projIndex" v-if="columns[34].visible"/>
      <el-table-column label="附注" align="center" prop="comments" v-if="columns[35].visible"/>
      <el-table-column label="摘要" align="center" prop="abstracts" v-if="columns[36].visible"/>
      <el-table-column label="关键字" align="center" prop="keywords" v-if="columns[37].visible"/>
      <el-table-column label="电子文件存放路径" align="center" prop="filepath" v-if="columns[38].visible"/>
      <el-table-column label="文件信息预留1" align="center" prop="fileReserved1" v-if="columns[39].visible"/>
      <!--      <el-table-column label="${comment}" align="center" prop="fileReserved2" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" v-if="columns[40].visible">
        <template slot-scope="scope">
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-edit"-->
<!--            @click="handleUpdate(scope.row)"-->
<!--            v-hasPermi="['system:file:edit']"-->
<!--          >修改</el-button>-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:file:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改文件对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="电子档案案卷表" prop="eaid">
          <el-input v-model="form.eaid" placeholder="请输入电子档案案卷表" />
        </el-form-item>
        <el-form-item label="案卷级档案表" prop="aid">
          <el-input v-model="form.aid" placeholder="请输入案卷级档案表" />
        </el-form-item>
        <el-form-item label="文件名" prop="wenJianName">
          <el-input v-model="form.wenJianName" placeholder="请输入文件名" />
        </el-form-item>
        <el-form-item label="文件数" prop="pageShu">
          <el-input v-model="form.pageShu" placeholder="请输入文件数" />
        </el-form-item>
        <el-form-item label="文件目录" prop="fileDirectory">
          <el-input v-model="form.fileDirectory" placeholder="请输入文件目录" />
        </el-form-item>
        <el-form-item label="状态值" prop="state">
          <el-input v-model="form.state" placeholder="请输入状态值 0：表示未被绑定  1：表示已被绑定" />
        </el-form-item>
        <el-form-item label="创建时间" prop="creationTime">
          <el-date-picker clearable
                          v-model="form.creationTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="文件id" prop="fileId">
          <el-input v-model="form.fileId" placeholder="请输入文件id" />
        </el-form-item>
        <el-form-item label="文件编号" prop="efilenum">
          <el-input v-model="form.efilenum" placeholder="请输入文件编号" />
        </el-form-item>
        <!--        <el-form-item label="${comment}" prop="listnum">-->
        <!--          <el-input v-model="form.listnum" placeholder="请输入${comment}" />-->
        <!--        </el-form-item>-->
        <el-form-item label="列表号" prop="listId">
          <el-input v-model="form.listId" placeholder="请输入列表号" />
        </el-form-item>
        <el-form-item label="索引id" prop="indexId">
          <el-input v-model="form.indexId" placeholder="请输入索引id" />
        </el-form-item>
        <el-form-item label="案卷ID" prop="volumeid">
          <el-input v-model="form.volumeid" placeholder="请输入案卷ID" />
        </el-form-item>
        <el-form-item label="旧案卷ID" prop="oldvolumeid">
          <el-input v-model="form.oldvolumeid" placeholder="请输入旧案卷ID" />
        </el-form-item>
        <el-form-item label="文件题名" prop="filename">
          <el-input v-model="form.filename" placeholder="请输入文件题名" />
        </el-form-item>
        <el-form-item label="责任者" prop="duty">
          <el-input v-model="form.duty" placeholder="请输入责任者" />
        </el-form-item>
        <el-form-item label="文件编号" prop="tagnum">
          <el-input v-model="form.tagnum" placeholder="请输入文件编号" />
        </el-form-item>
        <!--        <el-form-item label="${comment}" prop="filenum">-->
        <!--          <el-input v-model="form.filenum" placeholder="请输入${comment}" />-->
        <!--        </el-form-item>-->
        <el-form-item label="主题词" prop="thematic">
          <el-input v-model="form.thematic" placeholder="请输入主题词" />
        </el-form-item>
        <el-form-item label="创建时间" prop="ctime">
          <el-date-picker clearable
                          v-model="form.ctime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="页数" prop="pagenumber">
          <el-input v-model="form.pagenumber" placeholder="请输入页数" />
        </el-form-item>
        <el-form-item label="密级" prop="securitylayer">
          <el-input v-model="form.securitylayer" placeholder="请输入密级" />
        </el-form-item>
        <el-form-item label="文件类型" prop="filetype">
          <el-select v-model="form.filetype" placeholder="请选择文件类型">
            <el-option
              v-for="item in filetypeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="保存期限" prop="savetime">
          <el-input v-model="form.savetime" placeholder="请输入保存期限" />
        </el-form-item>
        <el-form-item label="文件时间" prop="filetime">
          <el-date-picker clearable
                          v-model="form.filetime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择文件时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="文件号" prop="fileno">
          <el-input v-model="form.fileno" placeholder="请输入文件号" />
        </el-form-item>
        <el-form-item label="附件" prop="fileatt">
          <el-input v-model="form.fileatt" placeholder="请输入附件" />
        </el-form-item>
        <el-form-item label="载体类型" prop="carriertype">
          <el-input v-model="form.carriertype" placeholder="请输入载体类型" />
        </el-form-item>
        <el-form-item label="文件总数量" prop="totalnum">
          <el-input v-model="form.totalnum" placeholder="请输入文件总数量" />
        </el-form-item>
        <el-form-item label="总数量" prop="total">
          <el-input v-model="form.total" placeholder="请输入总数量" />
        </el-form-item>
        <el-form-item label="纸张类型" prop="papertype">
          <el-input v-model="form.papertype" placeholder="请输入纸张类型" />
        </el-form-item>
        <el-form-item label="建设单位" prop="buildorganization">
          <el-input v-model="form.buildorganization" placeholder="请输入建设单位" />
        </el-form-item>
        <el-form-item label="编制单位" prop="wcompanyId">
          <el-input v-model="form.wcompanyId" placeholder="请输入编制单位" />
        </el-form-item>
        <el-form-item label="档号" prop="vnum">
          <el-input v-model="form.vnum" placeholder="请输入档号" />
        </el-form-item>
        <el-form-item label="是否归档" prop="isArchived">
          <el-input v-model="form.isArchived" placeholder="请输入是否归档" />
        </el-form-item>
        <el-form-item label="项目索引" prop="projIndex">
          <el-input v-model="form.projIndex" placeholder="请输入项目索引" />
        </el-form-item>
        <el-form-item label="附注" prop="comments">
          <el-input v-model="form.comments" placeholder="请输入附注" />
        </el-form-item>
        <el-form-item label="摘要" prop="abstracts">
          <el-input v-model="form.abstracts" placeholder="请输入摘要" />
        </el-form-item>
        <el-form-item label="关键字" prop="keywords">
          <el-input v-model="form.keywords" placeholder="请输入关键字" />
        </el-form-item>
        <el-form-item label="电子文件存放路径" prop="filepath">
          <el-input v-model="form.filepath" placeholder="请输入电子文件存放路径" />
        </el-form-item>
        <el-form-item label="文件信息预留1" prop="fileReserved1">
          <el-input v-model="form.fileReserved1" placeholder="请输入文件信息预留1" />
        </el-form-item>
        <!--        <el-form-item label="${comment}" prop="fileReserved2">-->
        <!--          <el-input v-model="form.fileReserved2" placeholder="请输入${comment}" />-->
        <!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listFile, getFile, delFile, addFile, updateFile } from "@/api/system/file";

export default {
  name: "File",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 文件表格数据
      fileList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        eaid: null,
        aid: null,
        wenJianName: null,
        pageShu: null,
        fileDirectory: null,
        state: null,
        creationTime: null,
        fileId: null,
        efilenum: null,
        listnum: null,
        listId: null,
        indexId: null,
        volumeid: null,
        oldvolumeid: null,
        filename: null,
        duty: null,
        tagnum: null,
        filenum: null,
        thematic: null,
        ctime: null,
        pagenumber: null,
        securitylayer: null,
        filetype: null,
        savetime: null,
        filetime: null,
        fileno: null,
        fileatt: null,
        carriertype: null,
        totalnum: null,
        total: null,
        papertype: null,
        buildorganization: null,
        wcompanyId: null,
        vnum: null,
        isArchived: null,
        projIndex: null,
        comments: null,
        abstracts: null,
        keywords: null,
        filepath: null,
        fileReserved1: null,
        fileReserved2: null
      },
      // 表单参数
      form: {},
      columns: [
        { key: 0, label: `编号`, visible: false },
        { key: 1, label: `电子档案案卷表`, visible: false },
        { key: 2, label: `案卷级档案表`, visible: false },
        { key: 3, label: `文件名`, visible: true },
        { key: 4, label: `文件数`, visible: false },
        { key: 5, label: `文件目录`, visible: false },
        { key: 6, label: `状态值`, visible: false },
        { key: 7, label: `创建时间`, visible: false },
        { key: 8, label: `文件id`, visible: false },
        { key: 9, label: `文件编号`, visible: false },
        { key: 10, label: `列表号`, visible: false },
        { key: 11, label: `索引id`, visible: false },
        { key: 12, label: `案卷ID`, visible: false },
        { key: 13, label: `旧案卷ID`, visible: false },
        { key: 14, label: `文件题名`, visible: true },
        { key: 15, label: `责任者`, visible: true },
        { key: 16, label: `文件编号`, visible: false },
        { key: 17, label: `主题词`, visible: true },
        { key: 18, label: `创建时间`, visible: false },
        { key: 19, label: `页数`, visible: false },
        { key: 20, label: `密级`, visible: false },
        { key: 21, label: `文件类型`, visible: false },
        { key: 22, label: `保存期限`, visible: true },
        { key: 23, label: `文件时间`, visible: true },
        { key: 24, label: `文件号`, visible: false },
        { key: 25, label: `附件`, visible: false },
        { key: 26, label: `载体类型`, visible: false },
        { key: 27, label: `文件总数量`, visible: true },
        { key: 28, label: `总数量`, visible: false },
        { key: 29, label: `纸张类型`, visible: false },
        { key: 30, label: `建设单位`, visible: false },
        { key: 31, label: `编制单位`, visible: false },
        { key: 32, label: `档号`, visible: false },
        { key: 33, label: `是否归档`, visible: true },
        { key: 34, label: `项目索引`, visible: false },
        { key: 35, label: `附注`, visible: false },
        { key: 36, label: `摘要`, visible: false },
        { key: 37, label: `关键字`, visible: false },
        { key: 38, label: `电子文件存放路径`, visible: true },
        { key: 39, label: `文件信息预留1`, visible: false },
        { key: 40, label: `操作`, visible: true },
      ],
      filetypeOptions: [
        { value: 'jpg', label: 'jpg' },
        { value: 'jpeg', label: 'jpeg' },
        { value: 'gif', label: 'gif' },
        { value: 'pdf', label: 'pdf' }
      ],
      // 表单校验
      rules: {
        eaid: [
          { required: true, message: "外键，电子档案案卷表不能为空", trigger: "blur" }
        ],
        isArchived: [
          { required: true, message: "是否归档不能为空", trigger: "blur" }
        ],
        filetype: [
          { required: true, message: '请选择文件类型', trigger: 'change' },
          { required: true, message: "文件类型不能为空", trigger: "blur" },
          {
            validator: (rule, value, callback) => {
              if (value) {
                const validExtensions = ['pdf', 'tif','tiff','jpg','png','jpeg'];
                if (validExtensions.includes(value.toLowerCase())) {
                  callback(); // 验证通过
                } else {
                  callback(new Error('文件类型必须为 PDF , TIF , TIFF , JPG , PNG , JPEG')); // 验证失败
                }
              } else {
                // 如果 value 为空，那么之前的 required 规则会处理这个情况
                callback();
              }
            },
            trigger: "blur"
          }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询文件列表 */
    getList() {
      this.loading = true;
      listFile(this.queryParams).then(response => {
        this.fileList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        eaid: null,
        aid: null,
        wenJianName: null,
        pageShu: null,
        fileDirectory: null,
        state: null,
        creationTime: null,
        fileId: null,
        efilenum: null,
        listnum: null,
        listId: null,
        indexId: null,
        volumeid: null,
        oldvolumeid: null,
        filename: null,
        duty: null,
        tagnum: null,
        filenum: null,
        thematic: null,
        ctime: null,
        pagenumber: null,
        securitylayer: null,
        filetype: null,
        savetime: null,
        filetime: null,
        fileno: null,
        fileatt: null,
        carriertype: null,
        totalnum: null,
        total: null,
        papertype: null,
        buildorganization: null,
        wcompanyId: null,
        vnum: null,
        isArchived: null,
        projIndex: null,
        comments: null,
        abstracts: null,
        keywords: null,
        filepath: null,
        fileReserved1: null,
        fileReserved2: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加文件";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getFile(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改文件";
      });
    },
    async handleUpdate1(row) {
      console.log("111111");
      this.reset();
      const id = row.id || this.ids;
      console.log(id);
      const response = await getFile(id);
      this.form = {...response.data};
      // getFile(id).then(response => {
      //   this.form = response.data;
      // });
      this.form.wenJianName = 111;
     await updateFile(this.form).then(response => {
        this.getList();
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateFile(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addFile(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除文件编号为"' + ids + '"的数据项？').then(function() {
        return delFile(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/file/export', {
        ...this.queryParams
      }, `file_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
